package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 精神病患者随访第二页
 * 
 * 
 * @author sunping
 */
public class EditVisitMentalSecondActivity extends AbstractControlActivity
		implements OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_edit_mental_second);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_learning_ability, "学习能力");
		addRadioGroupView(R.id.rad_interpersonal, "社会人际交往");
		addEditTextView(R.id.edt_mild_trouble, "轻度滋事 ");
		addEditTextView(R.id.edt_accident, "肇事");
		addEditTextView(R.id.edt_troublemaking, "肇祸");
		addEditTextView(R.id.edt_self_injury, "自伤");
		addEditTextView(R.id.edt_attempted_suicide, "自杀未遂");
		addRadioGroupView(R.id.rad_lock, "关锁情况");
		addRadioGroupView(R.id.rad_hospitalized, "住院情况");
		addEditTextView(R.id.edt_last_time, "末次住院时间");
		addRadioGroupView(R.id.rad_laboratory_examination, "实验室检查");
		addRadioGroupView(R.id.rad_compliance, "服药依从性");
		addRadioGroupView(R.id.rad_drug_reactions, "药物不良反应");
		addRadioGroupView(R.id.rad_treatment, "治疗效果");

		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(EditPersonDocFirstActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_last_time);
		setButtonListener(this, R.id.btn_previous, R.id.btn_next);
	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		int clickId = (Integer) v.getId();
		switch (clickId) {
		case R.id.btn_next:
			controlManager.toProperties();
			intent.setClass(this, EditVisitMentalThirdActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			finish();
			break;
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, EditVisitMentalFirstActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			finish();
			break;
		default:
			break;
		}

	}

}
